package com.itheima.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

@Mapper
public interface SetmealGroupMapper {

    /**
     * 根据套餐id查询检查组id
     * @param setmealId
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    ArrayList<Integer> findCheckGroupIdsBySetmealId(Integer setmealId);


    /**
     * 添加套餐和检查组关联关系
     * @param setmealId
     * @param checkgroupId
     */
    @Select("insert into t_setmeal_checkgroup (setmeal_id, checkgroup_id) values (#{setmealId},#{checkgroupId})")
    void insert(@Param("setmealId") Integer setmealId,@Param("checkgroupId") Integer checkgroupId);

    /**
     * 根据套餐id删除套餐和检查组关联关系
     * @param setmealId
     */
    @Select("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void deleteBySetmealId(Integer setmealId);
}
